package com.xtsoft.platform.base.system.domain;

/*
*    上海信拓信息技术有限公司  
*    Copyright (C) ShangHai XinTuo Software Inc.
*/

import com.fasterxml.jackson.annotation.JsonIgnore;

import com.xtsoft.core.entity.GenericEntity;
import com.xtsoft.platform.globe.enums.YesNo;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import jakarta.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * SysRegion Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 * TODO: add class/table comments
 */
@Entity
@Table(name = "sys_region")
@Data
//@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class SysRegion extends GenericEntity {


	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(name="regUniqueId",nullable=false,length=32)
    private String regUniqueId;


	/**
	*   行政区代码
	*/
	@Column(name="regionId",nullable=false, length=32 )
	private String regionId;


	/**
	*   行政区域名称
	*/
	@Column(name="regionName",nullable=false, length=128 )
	private String regionName;


	/**
	*   上级行政区域
	*/
	@Column(name="preRegionId",nullable=true, length=32 )
	private String preRegionId;


	/**
	*   是否直属局
	*/
	@Column(name="isDirectlyBureau",nullable=true, length=10 )
	private Integer isDirectlyBureau;


	/**
	*   状态
	*/
	@Column(name="state",nullable=false, length=10 )
	private Integer state;


	/**
	*   说明
	*/
	@Column(name="descript",nullable=true, length=255 )
	private String descript;


	@OneToMany(cascade={CascadeType.ALL},mappedBy = "sysRegion", fetch = FetchType.LAZY)
	@JsonIgnore
	//@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
	private List<SysOrganize> sysOrganizes = new ArrayList();
	
	public SysRegion addSysOrganize(SysOrganize sysOrganize){
		sysOrganizes.add(sysOrganize);
		sysOrganize.setSysRegion(this);
		return this;
	}
	
	public SysRegion removeSysOrganize(SysOrganize sysOrganize){
		sysOrganizes.remove(sysOrganize);
		sysOrganize.setSysRegion(null);
		return this;
	}
	
	/**
	 *  默认构造
	 */

	public SysRegion(){

	}
	/**
	*  构造方法，自动测试使用，把除主键外的所有非空字段赋值
	*
	*  也可作普通使用  调用该构造方法时，字串参数填或不填均
	*  可，该带参构造方法仅为区别Lombok自动生成的默认构造方
	*  法。
	*  
	*  应用程序可根据需要修改该构造方法中的非空属性赋值。
	**/
	public SysRegion(String forAutoTest){

		this.regionId = "New string";


		this.regionName = "New string";


		this.state = YesNo.Yes.getIntValue();

	}
	
	@Override  
	public boolean equals(Object obj) {  
	    if (obj instanceof SysRegion) {  
	        return this.regUniqueId.equals(((SysRegion) obj).getRegUniqueId());  
	    }  
	    return false;  
	}  	

	@Override  
	public int hashCode() {  
	    return this.regUniqueId.hashCode();  
	} 	
}
